[XEN] vga code cleanups and additions for other architectures.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 16 Aug 2006 17:20:03 +0000 (18:20 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 16 Aug 2006 17:20:03 +0000 (18:20 +0100)
Based on patches from Hollis Blanchard and Alex Williamson.
Signed-off-by: Keir Fraser <keir@xensource.com>
19 files changed:
linux-2.6-xen-sparse/arch/ia64/dig/setup.c [new file with mode: 0644]
xen/arch/ia64/Rules.mk
xen/arch/ia64/xen/domain.c
xen/arch/ia64/xen/mm.c
xen/arch/x86/Rules.mk
xen/arch/x86/mm.c
xen/drivers/Makefile
xen/drivers/char/console.c
xen/drivers/video/font.h [new file with mode: 0644]
xen/drivers/video/font_8x14.c
xen/drivers/video/font_8x16.c
xen/drivers/video/font_8x8.c
xen/drivers/video/vga.c
xen/include/asm-ia64/config.h
xen/include/asm-x86/config.h
xen/include/asm-x86/io.h
xen/include/xen/font.h [deleted file]
xen/include/xen/mm.h
xen/include/xen/vga.h

diff --git a/linux-2.6-xen-sparse/arch/ia64/dig/setup.c b/linux-2.6-xen-sparse/arch/ia64/dig/setup.c
new file mode 100644 (file)
index 0000000..ebe45c7
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Platform dependent support for DIG64 platforms.
+ *
+ * Copyright (C) 1999 Intel Corp.
+ * Copyright (C) 1999, 2001 Hewlett-Packard Co
+ * Copyright (C) 1999, 2001, 2003 David Mosberger-Tang <davidm@hpl.hp.com>
+ * Copyright (C) 1999 VA Linux Systems
+ * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
+ * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
+ */
+#include <linux/config.h>
+
+#include <linux/init.h>
+#include <linux/delay.h>
+#include <linux/kernel.h>
+#include <linux/kdev_t.h>
+#include <linux/string.h>
+#include <linux/tty.h>
+#include <linux/console.h>
+#include <linux/timex.h>
+#include <linux/sched.h>
+#include <linux/root_dev.h>
+
+#include <asm/io.h>
+#include <asm/machvec.h>
+#include <asm/system.h>
+
+void __init
+dig_setup (char **cmdline_p)
+{
+       unsigned int orig_x, orig_y, num_cols, num_rows, font_height;
+
+       /*
+        * Default to /dev/sda2.  This assumes that the EFI partition
+        * is physical disk 1 partition 1 and the Linux root disk is
+        * physical disk 1 partition 2.
+        */
+       ROOT_DEV = Root_SDA2;           /* default to second partition on first drive */
+
+#ifdef CONFIG_SMP
+       init_smp_config();
+#endif
+
+       memset(&screen_info, 0, sizeof(screen_info));
+
+       if (!ia64_boot_param->console_info.num_rows
+           || !ia64_boot_param->console_info.num_cols)
+       {
+               printk(KERN_WARNING "dig_setup: warning: invalid screen-info, guessing 80x25\n");
+               orig_x = 0;
+               orig_y = 0;
+               num_cols = 80;
+               num_rows = 25;
+               font_height = 16;
+       } else {
+               orig_x = ia64_boot_param->console_info.orig_x;
+               orig_y = ia64_boot_param->console_info.orig_y;
+               num_cols = ia64_boot_param->console_info.num_cols;
+               num_rows = ia64_boot_param->console_info.num_rows;
+               font_height = 400 / num_rows;
+       }
+
+       screen_info.orig_x = orig_x;
+       screen_info.orig_y = orig_y;
+       screen_info.orig_video_cols  = num_cols;
+       screen_info.orig_video_lines = num_rows;
+       screen_info.orig_video_points = font_height;
+       screen_info.orig_video_mode = 3;        /* XXX fake */
+       screen_info.orig_video_isVGA = 1;       /* XXX fake */
+       screen_info.orig_video_ega_bx = 3;      /* XXX fake */
+#ifdef CONFIG_XEN
+       if (!is_running_on_xen())
+               return;
+
+       if (xen_start_info->console.dom0.info_size >=
+           sizeof(struct dom0_vga_console_info)) {
+               const struct dom0_vga_console_info *info =
+                       (struct dom0_vga_console_info *)(
+                               (char *)xen_start_info +
+                               xen_start_info->console.dom0.info_off);
+               screen_info.orig_video_mode = info->txt_mode;
+               screen_info.orig_video_isVGA = info->video_type;
+               screen_info.orig_video_lines = info->video_height;
+               screen_info.orig_video_cols = info->video_width;
+               screen_info.orig_video_points = info->txt_points;
+               screen_info.lfb_width = info->video_width;
+               screen_info.lfb_height = info->video_height;
+               screen_info.lfb_depth = info->lfb_depth;
+               screen_info.lfb_base = info->lfb_base;
+               screen_info.lfb_size = info->lfb_size;
+               screen_info.lfb_linelength = info->lfb_linelen;
+               screen_info.red_size = info->red_size;
+               screen_info.red_pos = info->red_pos;
+               screen_info.green_size = info->green_size;
+               screen_info.green_pos = info->green_pos;
+               screen_info.blue_size = info->blue_size;
+               screen_info.blue_pos = info->blue_pos;
+               screen_info.rsvd_size = info->rsvd_size;
+               screen_info.rsvd_pos = info->rsvd_pos;
+       }
+       screen_info.orig_y = screen_info.orig_video_lines - 1;
+       xen_start_info->console.domU.mfn = 0;
+       xen_start_info->console.domU.evtchn = 0;
+#endif
+}
+
+void __init
+dig_irq_init (void)
+{
+}
index 030a9e2f1d5a24f0f0c6fb12ea562480980de4a1..3c8663c90be73fce2ce25c14836bd62f445102ce 100644 (file)
@@ -2,6 +2,7 @@
 # ia64-specific definitions
 
 HAS_ACPI := y
+HAS_VGA  := y
 VALIDATE_VT    ?= n
 no_warns ?= n
 
index 55ce4b7868ba741f7db57409475ced5c8ffad2cd..9fbcec8a71d6f19962517b2d8b58fd93b9cd63aa 100644 (file)
@@ -864,6 +864,7 @@ int construct_dom0(struct domain *d,
 {
        int i, rc;
        start_info_t *si;
+       dom0_vga_console_info_t *ci;
        struct vcpu *v = d->vcpu[0];
        unsigned long max_pages;
 
@@ -1000,6 +1001,9 @@ int construct_dom0(struct domain *d,
        //if ( initrd_len != 0 )
        //    memcpy((void *)vinitrd_start, initrd_start, initrd_len);
 
+       BUILD_BUG_ON(sizeof(start_info_t) + sizeof(dom0_vga_console_info_t) +
+                    sizeof(struct ia64_boot_param) > PAGE_SIZE);
+
        /* Set up start info area. */
        d->shared_info->arch.start_info_pfn = pstart_info >> PAGE_SHIFT;
        start_info_page = assign_new_domain_page(d, pstart_info);
@@ -1034,7 +1038,8 @@ int construct_dom0(struct domain *d,
        strncpy((char *)si->cmd_line, dom0_command_line, sizeof(si->cmd_line));
        si->cmd_line[sizeof(si->cmd_line)-1] = 0;
 
-       bp = (struct ia64_boot_param *)(si + 1);
+       bp = (struct ia64_boot_param *)((unsigned char *)si +
+                                       sizeof(start_info_t));
        bp->command_line = pstart_info + offsetof (start_info_t, cmd_line);
 
        /* We assume console has reached the last line!  */
@@ -1048,6 +1053,16 @@ int construct_dom0(struct domain *d,
                     (PAGE_ALIGN(ia64_boot_param->initrd_size) + 4*1024*1024);
        bp->initrd_size = ia64_boot_param->initrd_size;
 
+       ci = (dom0_vga_console_info_t *)((unsigned char *)si +
+                                        sizeof(start_info_t) +
+                                        sizeof(struct ia64_boot_param));
+
+       if (fill_console_start_info(ci)) {
+               si->console.dom0.info_off = sizeof(start_info_t) +
+                                           sizeof(struct ia64_boot_param);
+               si->console.dom0.info_size = sizeof(dom0_vga_console_info_t);
+       }
+
        vcpu_init_regs (v);
 
        vcpu_regs(v)->r28 = bp_mpa;
index ec4927f36b1e9a82abac13b74b236f6838983992..de195765704b23c29181a4a983f3c7315767f614 100644 (file)
@@ -1746,6 +1746,11 @@ int get_page_type(struct page_info *page, u32 type)
     return 1;
 }
 
+int memory_is_conventional_ram(paddr_t p)
+{
+    return (efi_mem_type(p) == EFI_CONVENTIONAL_MEMORY);
+}
+
 /*
  * Local variables:
  * mode: C
index 399a1cce4be3ac93edbfccbfa1e36ed439bc7b30..e91c8bf02d16d48ab953afab55b011c527a42e60 100644 (file)
@@ -2,6 +2,7 @@
 # x86-specific definitions
 
 HAS_ACPI := y
+HAS_VGA  := y
 
 #
 # If you change any of these configuration options then you must
index 6c0abad2e2ca199c0f8bc8f93f426e7088485a44..7cf9ce924a73cd21b4601d8a3913cc1c7b52bec6 100644 (file)
@@ -234,6 +234,21 @@ void arch_init_memory(void)
     subarch_init_memory();
 }
 
+int memory_is_conventional_ram(paddr_t p)
+{
+    int i;
+
+    for ( i = 0; i < e820.nr_map; i++ )
+    {
+        if ( (e820.map[i].type == E820_RAM) &&
+             (e820.map[i].addr <= p) &&
+             (e820.map[i].size > p) )
+            return 1;
+    }
+
+    return 0;
+}
+
 void share_xen_page_with_guest(
     struct page_info *page, struct domain *d, int readonly)
 {
index 1d4c93fbbb4ff5cc8082555651d67b5dfd97dd12..d622373c11302dc58aa499f1cbaef6890ac448c6 100644 (file)
@@ -1,3 +1,3 @@
 subdir-y += char
 subdir-$(HAS_ACPI) += acpi
-subdir-y += video
+subdir-$(HAS_VGA) += video
index 974f6e3d8e96c28f1ac4554a2ef03a7460d6d12f..f516230c2971429858efb7ccad81aa27b33cb3d0 100644 (file)
@@ -22,7 +22,6 @@
 #include <xen/delay.h>
 #include <xen/guest_access.h>
 #include <xen/shutdown.h>
-#include <xen/font.h>
 #include <xen/vga.h>
 #include <asm/current.h>
 #include <asm/debugger.h>
 static char opt_console[30] = OPT_CONSOLE_STR;
 string_param("console", opt_console);
 
-/* vga: comma-separated options. */
-static char opt_vga[30] = "";
-string_param("vga", opt_vga);
-
 /* conswitch: a character pair controlling console switching. */
 /* Char 1: CTRL+<char1> is used to switch console input between Xen and DOM0 */
 /* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
@@ -47,9 +42,6 @@ string_param("conswitch", opt_conswitch);
 static int opt_sync_console;
 boolean_param("sync_console", opt_sync_console);
 
-static int xpos, ypos;
-static unsigned char *video;
-
 #define CONRING_SIZE 16384
 #define CONRING_IDX_MASK(i) ((i)&(CONRING_SIZE-1))
 static char conring[CONRING_SIZE];
@@ -58,135 +50,9 @@ static unsigned int conringc, conringp;
 static char printk_prefix[16] = "";
 
 static int sercon_handle = -1;
-static int vgacon_enabled = 0;
-static int vgacon_keep    = 0;
-static int vgacon_lines   = 25;
-static const struct font_desc *font;
 
 static DEFINE_SPINLOCK(console_lock);
 
-/*
- * *******************************************************
- * *************** OUTPUT TO VGA CONSOLE *****************
- * *******************************************************
- */
-
-/* VGA text-mode definitions. */
-#define COLUMNS     80
-#define LINES       vgacon_lines
-#define ATTRIBUTE   7
-#define VIDEO_SIZE  (COLUMNS * LINES * 2)
-
-/* Clear the screen and initialize VIDEO, XPOS and YPOS.  */
-static void cls(void)
-{
-    memset(video, 0, VIDEO_SIZE);
-    xpos = ypos = 0;
-    vga_cursor_off();
-}
-
-static void init_vga(void)
-{
-    char *p;
-
-    if ( !vgacon_enabled )
-        return;
-
-    for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
-    {
-        if ( *p == ',' )
-            p++;
-        if ( strncmp(p, "keep", 4) == 0 )
-            vgacon_keep = 1;
-        else if ( strncmp(p, "text-80x", 8) == 0 )
-            vgacon_lines = simple_strtoul(p + 8, NULL, 10);
-    }
-
-    video = setup_vga();
-    if ( !video )
-    {
-        vgacon_enabled = 0;
-        return;
-    }
-
-    switch ( vgacon_lines )
-    {
-    case 25:
-    case 30:
-        font = &font_vga_8x16;
-        break;
-    case 28:
-    case 34:
-        font = &font_vga_8x14;
-        break;
-    case 43:
-    case 50:
-    case 60:
-        font = &font_vga_8x8;
-        break;
-    default:
-        vgacon_lines = 25;
-        break;
-    }
-
-    if ( (font != NULL) && (vga_load_font(font, vgacon_lines) < 0) )
-    {
-        vgacon_lines = 25;
-        font = NULL;
-    }
-    
-    cls();
-}
-
-static void put_newline(void)
-{
-    xpos = 0;
-    ypos++;
-
-    if ( ypos >= LINES )
-    {
-        ypos = LINES-1;
-        memmove((char*)video, 
-                (char*)video + 2*COLUMNS, (LINES-1)*2*COLUMNS);
-        memset((char*)video + (LINES-1)*2*COLUMNS, 0, 2*COLUMNS);
-    }
-}
-
-static void putchar_console(int c)
-{
-    if ( !vgacon_enabled )
-        return;
-
-    if ( c == '\n' )
-    {
-        put_newline();
-    }
-    else
-    {
-        if ( xpos >= COLUMNS )
-            put_newline();
-        video[(xpos + ypos * COLUMNS) * 2]     = c & 0xFF;
-        video[(xpos + ypos * COLUMNS) * 2 + 1] = ATTRIBUTE;
-        ++xpos;
-    }
-}
-
-int fill_console_start_info(struct dom0_vga_console_info *ci)
-{
-    memset(ci, 0, sizeof(*ci));
-
-    if ( !vgacon_enabled )
-        return 0;
-
-    ci->video_type   = 1;
-    ci->video_width  = COLUMNS;
-    ci->video_height = LINES;
-    ci->txt_mode     = 3;
-    ci->txt_points   = font ? font->height : 16;
-
-    return 1;
-}
-
 /*
  * ********************************************************
  * *************** ACCESS TO CONSOLE RING *****************
@@ -328,7 +194,7 @@ static long guest_console_write(XEN_GUEST_HANDLE(char) buffer, int count)
         serial_puts(sercon_handle, kbuf);
 
         for ( kptr = kbuf; *kptr != '\0'; kptr++ )
-            putchar_console(*kptr);
+            vga_putchar(*kptr);
 
         guest_handle_add_offset(buffer, kcount);
         count -= kcount;
@@ -395,7 +261,7 @@ static inline void __putstr(const char *str)
 
     while ( (c = *str++) != '\0' )
     {
-        putchar_console(c);
+        vga_putchar(c);
         putchar_console_ring(c);
     }
 }
@@ -455,11 +321,9 @@ void init_console(void)
         if ( strncmp(p, "com", 3) == 0 )
             sercon_handle = serial_parse_handle(p);
         else if ( strncmp(p, "vga", 3) == 0 )
-            vgacon_enabled = 1;
+            vga_init();
     }
 
-    init_vga();
-
     serial_set_rx_handler(sercon_handle, serial_rx);
 
     /* HELLO WORLD --- start-of-day banner text. */
@@ -510,10 +374,7 @@ void console_endboot(void)
         printk("\n");
     }
 
-    if ( !vgacon_keep )
-        vgacon_enabled = 0;
-    printk("Xen is %s VGA console.\n",
-           vgacon_keep ? "keeping" : "relinquishing");
+    vga_endboot();
 
     /*
      * If user specifies so, we fool the switch routine to redirect input
diff --git a/xen/drivers/video/font.h b/xen/drivers/video/font.h
new file mode 100644 (file)
index 0000000..7f720b3
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ *  font.h -- `Soft' font definitions
+ *
+ *  Created 1995 by Geert Uytterhoeven
+ *
+ *  This file is subject to the terms and conditions of the GNU General Public
+ *  License.  See the file COPYING in the main directory of this archive
+ *  for more details.
+ */
+
+#ifndef _XEN_FONT_H
+#define _XEN_FONT_H
+
+struct font_desc {
+    const char *name;
+    unsigned width, height, count;
+    const void *data;
+};
+
+extern const struct font_desc font_vga_8x8, font_vga_8x14, font_vga_8x16;
+
+#endif /* _XEN_FONT_H */
index 022c809b1e1fd90d9737f05074b9fc04d53075f4..6a39f263af29b58244ebd0fb6979622b9265998a 100644 (file)
@@ -5,7 +5,7 @@
 /**********************************************/
 
 #include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
 
 #define FONTDATAMAX (256*14)
 
index 756f44f2185281e41b3dade5eb1b25c62ac3c08f..c65f98dcbbc3a014478813a76c3334c01ed43ed1 100644 (file)
@@ -5,7 +5,7 @@
 /**********************************************/
 
 #include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
 
 #define FONTDATAMAX (256*16)
 
index e84d8094f0ad3f05d76159c920dc5dbb0d152e21..9441429b423354828b2986aa88f77bf127dafd3e 100644 (file)
@@ -5,7 +5,7 @@
 /**********************************************/
 
 #include <xen/types.h>
-#include <xen/font.h>
+#include "font.h"
 
 #define FONTDATAMAX (256*8)
 
index 78cfae8eda2d9d19f41986deb4d95f065500fca4..b22e0fa12d31f50d4a97823aaf7eec2f9ae5d47b 100644 (file)
@@ -8,13 +8,14 @@
 #include <xen/compile.h>
 #include <xen/init.h>
 #include <xen/lib.h>
+#include <xen/mm.h>
 #include <xen/errno.h>
 #include <xen/event.h>
 #include <xen/spinlock.h>
 #include <xen/console.h>
-#include <xen/font.h>
 #include <xen/vga.h>
 #include <asm/io.h>
+#include "font.h"
 
 /* Some of the code below is taken from SVGAlib.  The original,
    unmodified copyright notice for that code is below. */
  * into a single 16-bit quantity */
 #define VGA_OUT16VAL(v, r)       (((v) << 8) | (r))
 
-#if defined(__i386__) || defined(__x86_64__)
-# define vgabase 0
-# define VGA_OUTW_WRITE
-# define vga_readb(x) (*(x))
-# define vga_writeb(x,y) (*(y) = (x))
-#endif
+#define vgabase 0         /* use in/out port-access macros  */
+#define VGA_OUTW_WRITE    /* can use outw instead of 2xoutb */
 
 /*
  * generic VGA port read/write
@@ -187,17 +184,17 @@ static inline void vga_io_w_fast(uint16_t port, uint8_t reg, uint8_t val)
 
 static inline uint8_t vga_mm_r(void __iomem *regbase, uint16_t port)
 {
-    return readb(regbase + port);
+    return readb((char *)regbase + port);
 }
 
 static inline void vga_mm_w(void __iomem *regbase, uint16_t port, uint8_t val)
 {
-    writeb(val, regbase + port);
+    writeb(val, (char *)regbase + port);
 }
 
 static inline void vga_mm_w_fast(void __iomem *regbase, uint16_t port, uint8_t reg, uint8_t val)
 {
-    writew(VGA_OUT16VAL(val, reg), regbase + port);
+    writew(VGA_OUT16VAL(val, reg), (char *)regbase + port);
 }
 
 static inline uint8_t vga_r(void __iomem *regbase, uint16_t port)
@@ -324,24 +321,8 @@ static int detect_video(void *video_base)
     return video_found;
 }
 
-static int detect_vga(void)
-{
-    /*
-     * Look at a number of well-known locations. Even if video is not at
-     * 0xB8000 right now, it will appear there when we set up text mode 3.
-     * 
-     * We assume if there is any sign of a video adaptor then it is at least
-     * VGA-compatible (surely noone runs CGA, EGA, .... these days?).
-     * 
-     * These checks are basically to detect headless server boxes.
-     */
-    return (detect_video(ioremap(0xA0000, 0x1000)) || 
-            detect_video(ioremap(0xB0000, 0x1000)) || 
-            detect_video(ioremap(0xB8000, 0x1000)));
-}
-
 /* This is actually code from vgaHWRestore in an old version of XFree86 :-) */
-void *setup_vga(void)
+static void *setup_vga(void)
 {
     /* The following VGA state was saved from a chip in text mode 3. */
     static unsigned char regs[] = {
@@ -358,13 +339,11 @@ void *setup_vga(void)
         0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x0c, 0x00, 0x0f, 0x08, 0x00
     };
 
+    char *video;
     int i, j;
 
-    if ( !detect_vga() )
-    {
-        printk("No VGA adaptor detected!\n");
-        return NULL;
-    }
+    if ( memory_is_conventional_ram(0xB8000) )
+        goto no_vga;
 
     inb(VGA_IS1_RC);
     outb(0x00, VGA_ATT_IW);
@@ -388,12 +367,19 @@ void *setup_vga(void)
     inb(VGA_IS1_RC);
     outb(0x20, VGA_ATT_IW);
 
-    return ioremap(0xB8000, 0x8000);
-}
+    video = ioremap(0xB8000, 0x8000);
 
-void vga_cursor_off(void)
-{
-    vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20);
+    if ( !detect_video(video) )
+    {
+        iounmap(video);
+        goto no_vga;
+    }
+
+    return video;
+
+ no_vga:
+    printk("No VGA adaptor detected!\n");
+    return NULL;
 }
 
 static int vga_set_scanlines(unsigned scanlines)
@@ -473,7 +459,7 @@ static int vga_set_scanlines(unsigned scanlines)
 static unsigned font_slot = 0;
 integer_param("fontslot", font_slot);
 
-int vga_load_font(const struct font_desc *font, unsigned rows)
+static int vga_load_font(const struct font_desc *font, unsigned rows)
 {
     unsigned fontheight = font ? font->height : 16;
     uint8_t fsr = vga_rcrt(vgabase, VGA_CRTC_MAX_SCAN); /* Font size register */
@@ -515,16 +501,19 @@ int vga_load_font(const struct font_desc *font, unsigned rows)
     {
         unsigned i, j;
         const uint8_t *data = font->data;
-        uint8_t *map = (uint8_t *)__va(0xA0000) + font_slot*2*CHAR_MAP_SIZE;
+        uint8_t *map;
+
+        map = ioremap(0xA0000 + font_slot*2*CHAR_MAP_SIZE, CHAR_MAP_SIZE);
 
         for ( i = j = 0; i < CHAR_MAP_SIZE; )
         {
-            vga_writeb(j < font->count * fontheight ? data[j++] : 0,
-                       map + i++);
+            writeb(j < font->count * fontheight ? data[j++] : 0, map + i++);
             if ( !(j % fontheight) )
                 while ( i & (FONT_HEIGHT_MAX - 1) )
-                    vga_writeb(0, map + i++);
+                    writeb(0, map + i++);
         }
+
+        iounmap(map);
     }
 
     /* First, the sequencer, Synchronous reset */
@@ -560,3 +549,142 @@ int vga_load_font(const struct font_desc *font, unsigned rows)
 
     return 0;
 }
+
+
+/*
+ * HIGH-LEVEL INITIALISATION AND TEXT OUTPUT.
+ */
+
+static int vgacon_enabled = 0;
+static int vgacon_keep    = 0;
+static int vgacon_lines   = 25;
+static const struct font_desc *font;
+
+static int xpos, ypos;
+static unsigned char *video;
+
+/* vga: comma-separated options. */
+static char opt_vga[30] = "";
+string_param("vga", opt_vga);
+
+/* VGA text-mode definitions. */
+#define COLUMNS     80
+#define LINES       vgacon_lines
+#define ATTRIBUTE   7
+#define VIDEO_SIZE  (COLUMNS * LINES * 2)
+
+void vga_init(void)
+{
+    char *p;
+
+    for ( p = opt_vga; p != NULL; p = strchr(p, ',') )
+    {
+        if ( *p == ',' )
+            p++;
+        if ( strncmp(p, "keep", 4) == 0 )
+            vgacon_keep = 1;
+        else if ( strncmp(p, "text-80x", 8) == 0 )
+            vgacon_lines = simple_strtoul(p + 8, NULL, 10);
+    }
+
+    video = setup_vga();
+    if ( !video )
+        return;
+
+    switch ( vgacon_lines )
+    {
+    case 25:
+    case 30:
+        font = &font_vga_8x16;
+        break;
+    case 28:
+    case 34:
+        font = &font_vga_8x14;
+        break;
+    case 43:
+    case 50:
+    case 60:
+        font = &font_vga_8x8;
+        break;
+    default:
+        vgacon_lines = 25;
+        break;
+    }
+
+    if ( (font != NULL) && (vga_load_font(font, vgacon_lines) < 0) )
+    {
+        vgacon_lines = 25;
+        font = NULL;
+    }
+    
+    /* Clear the screen. */
+    memset(video, 0, VIDEO_SIZE);
+    xpos = ypos = 0;
+
+    /* Disable cursor. */
+    vga_wcrt(vgabase, VGA_CRTC_CURSOR_START, 0x20);
+
+    vgacon_enabled = 1;
+}
+
+void vga_endboot(void)
+{
+    if ( !vgacon_enabled )
+        return;
+
+    if ( !vgacon_keep )
+        vgacon_enabled = 0;
+        
+    printk("Xen is %s VGA console.\n",
+           vgacon_keep ? "keeping" : "relinquishing");
+}
+
+
+static void put_newline(void)
+{
+    xpos = 0;
+    ypos++;
+
+    if ( ypos >= LINES )
+    {
+        ypos = LINES-1;
+        memmove((char*)video, 
+                (char*)video + 2*COLUMNS, (LINES-1)*2*COLUMNS);
+        memset((char*)video + (LINES-1)*2*COLUMNS, 0, 2*COLUMNS);
+    }
+}
+
+void vga_putchar(int c)
+{
+    if ( !vgacon_enabled )
+        return;
+
+    if ( c == '\n' )
+    {
+        put_newline();
+    }
+    else
+    {
+        if ( xpos >= COLUMNS )
+            put_newline();
+        video[(xpos + ypos * COLUMNS) * 2]     = c & 0xFF;
+        video[(xpos + ypos * COLUMNS) * 2 + 1] = ATTRIBUTE;
+        ++xpos;
+    }
+}
+
+int fill_console_start_info(struct dom0_vga_console_info *ci)
+{
+    memset(ci, 0, sizeof(*ci));
+
+    if ( !vgacon_enabled )
+        return 0;
+
+    ci->video_type   = 1;
+    ci->video_width  = COLUMNS;
+    ci->video_height = LINES;
+    ci->txt_mode     = 3;
+    ci->txt_points   = font ? font->height : 16;
+
+    return 1;
+}
index 12d48f7baf88e212845d4124a2109bb7f75a9d90..4d172c527711bf9d52634b5a0c708613606e62c0 100644 (file)
@@ -37,6 +37,8 @@
 
 #define MAX_DMADOM_PFN (0x7FFFFFFFUL >> PAGE_SHIFT) /* 31 addressable bits */
 
+#define CONFIG_VGA 1
+
 #ifndef __ASSEMBLY__
 
 // can't find where this typedef was before?!?
index 74a123de6f85637dce81709570772f6ed056d407..e2ef90700cc67f03b1bc1c6677b61736170c4363 100644 (file)
@@ -31,6 +31,8 @@
 #define CONFIG_ACPI 1
 #define CONFIG_ACPI_BOOT 1
 
+#define CONFIG_VGA 1
+
 #define HZ 100
 
 #define OPT_CONSOLE_STR "com1,vga"
index d393c1b6069389ff240d2f7144d360a0b7468dd8..968e7d35ce4d4de32ca03c14d93b6bf0364e09f7 100644 (file)
@@ -7,6 +7,7 @@
 
 /* We don't need real ioremap() on Xen/x86. */
 #define ioremap(x,l) (__va(x))
+#define iounmap(p)   ((void)0)
 
 #define readb(x) (*(volatile char *)(x))
 #define readw(x) (*(volatile short *)(x))
diff --git a/xen/include/xen/font.h b/xen/include/xen/font.h
deleted file mode 100644 (file)
index 7f720b3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- *  font.h -- `Soft' font definitions
- *
- *  Created 1995 by Geert Uytterhoeven
- *
- *  This file is subject to the terms and conditions of the GNU General Public
- *  License.  See the file COPYING in the main directory of this archive
- *  for more details.
- */
-
-#ifndef _XEN_FONT_H
-#define _XEN_FONT_H
-
-struct font_desc {
-    const char *name;
-    unsigned width, height, count;
-    const void *data;
-};
-
-extern const struct font_desc font_vga_8x8, font_vga_8x14, font_vga_8x16;
-
-#endif /* _XEN_FONT_H */
index d38fbed09ef18b6475fd031496ce63f7da086fc8..8c9713971b49b50d09e634d5472a553b7ddd26de 100644 (file)
@@ -97,4 +97,7 @@ unsigned long avail_scrub_pages(void);
 
 int guest_remove_page(struct domain *d, unsigned long gmfn);
 
+/* Returns TRUE if the memory at address @p is ordinary RAM. */
+int memory_is_conventional_ram(paddr_t p);
+
 #endif /* __XEN_MM_H__ */
index 9284b718225a574fa6cfd5d7ce97e854de92d36b..3431d625f78b03505ef15da7663d0d1f5052920b 100644 (file)
@@ -9,10 +9,16 @@
 #ifndef _XEN_VGA_H
 #define _XEN_VGA_H
 
-struct font_desc;
+#include <xen/config.h>
 
-void *setup_vga(void);
-void vga_cursor_off(void);
-int vga_load_font(const struct font_desc *, unsigned rows);
+#ifdef CONFIG_VGA
+void vga_init(void);
+void vga_endboot(void);
+void vga_putchar(int c);
+#else
+#define vga_init()     ((void)0)
+#define vga_endboot()  ((void)0)
+#define vga_putchar(c) ((void)0)
+#endif
 
 #endif /* _XEN_VGA_H */